//index.js
var app = getApp();
var request = app.request;
var util = require('../../../utils/util.js');

Page({
  data: {
    user: {},
    distribut: {},
    shopping: {},
    index_img: 1, // 须知
  },
  onShow: function () {
    this.commission();
  },
  // 用户须知
  changeTab: function (e) {
    var index_img = this.data.index_img;
    if (index_img == 1) {
      this.setData({
        index_img: 2
      });
    } else {
      this.setData({
        index_img: 1
      });
    }
  },
  commission: function () {
    var that = this;
    request.post('/api/Distribut/distribut_detail', {
      successReload: true,
      success: function (res) {
        if (res.data.result) {
          res.data.result.user["distribut_total_money"] = util.formatNumber(Number(res.data.result.user.distribut_money) + Number(res.data.result.user.distribut_withdrawals_money));
          res.data.result.user["distribut_withdrawalsing_money"] = util.formatNumber(Number(res.data.result.user.distribut_money) - Number(res.data.result.user.withdraw));
          that.setData({
            shopping: res.data.result.shopping,
            distribut: res.data.result.distribut,
            user: res.data.result.user
          })
        }
      }
    });
  },
})